<?php
class material_finder_material_replace{

    var $column_edit = '操作';
    var $column_edit_width = "75";
    function column_edit($row){
        return '<a href="index.php?app=material&ctl=admin_material_replace&act=edit&p[0]='.$row['rep_id'].'&finder_id='.$_GET[_finder][finder_id].'" target="_blank">编辑</a>';
    }

    var $column_use_expire='状态';
    function column_use_expire($row){
        $statusMdl = app::get('material')->model('basic_replace');
        $rep_id = $row['rep_id'];
        $status = $statusMdl->getList('disabled',array('rep_id'=>$rep_id));
        // error_log(print_r($status,1),3,DATA_DIR."/6666.log");
        if($status[0]['disabled'] == 'true'){
            return '开启';
        }else{
            return '关闭';
        }
    }

    var $column_shop='店铺名称';
    function column_shop($row){
        $statusMdl = app::get('material')->model('basic_replace');
        $shop      = app::get('ome')->model('shop');
        $rep_id    = $row['rep_id'];
        $shopIds   = $statusMdl->getList('shopIds',array('rep_id'=>$rep_id));
        $shoparray = explode(',',$shopIds[0]['shopIds']);
        $shoplist['shop_id'] = $shoparray;
        $shop_names= $shop->getList('name',$shoplist);
        if($shop_names) {
            foreach($shop_names as $key=>$name) {
                $shopstr .= $shop_names[$key]['name'];
                if($key>0) $shopstr .= ',';
            }
        }else {
            $shopstr   = $shopIds[0]['shopIds'];
        }
        return $shopstr;
    }

}

